﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.Common;
using System.Data.SqlClient;

using JM.JCY.BusinessEntity;
using JM.JCY.Common;
using JM.JCY.Common.Utilities;
using System.Data;

namespace JM.JCY.DataAccess
{
   public class PhotoAlbumDA:JCYDataAccessBasecs
    {
       public void CreateAlbumwithUpload(PhotoAlbumDataSet ds)
       {
           Helper.Update(ds);
       }

       public PhotoAlbumDataSet getAlbumDbyAlbumId(int albumId)
       {
           PhotoAlbumDataSet ds = new PhotoAlbumDataSet();

           string[] tableNames = new string[] { ds.T_SharePointObject.TableName, ds.T_Album.TableName.ToString(), ds.T_AlbumContent.TableName };
           base.Helper.Fill(ds, tableNames, "P_SharePointObject_S_AlbumId", albumId);
           return ds;
       }

       public PhotoAlbumSearchDataSet.T_UserCommitteeDataTable GetAllCommitteeUsersById(int committeeId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_UserCommittee, "P_UserCommittee_S_CommitteeId", committeeId);
           return ds.T_UserCommittee;
       }

       public PhotoAlbumSearchDataSet.T_UserDepartmentDataTable GetAllDepartmentUsersById(int departmentId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_UserDepartment, "P_UserDepartment_S_DepartmentId", departmentId);
           return ds.T_UserDepartment;
       }

       public PhotoAlbumSearchDataSet.T_AlbumContentDataTable GetAlbumContents(int albumId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_AlbumContent, "P_AlbumContent_S_AlbumId", albumId);
           return ds.T_AlbumContent;
       }

       public PhotoAlbumSearchDataSet.T_SearchLikeDataTable GetObjectLikCount(int objectId, string objType)
       {
           PhotoAlbumSearchDataSet.T_SearchLikeDataTable like = new PhotoAlbumSearchDataSet.T_SearchLikeDataTable();
           base.Helper.Fill(like, "P_T_Like_S_ObjectId", objectId, objType);
           return like;
       }

       public PhotoAlbumSearchDataSet.T_AlbumDataTable GetRecentlyUpdatedAlbums(string appType, int appId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_Album, "P_GetRecentlyUpdatedAlbums", appType, appId);
           return ds.T_Album;
       }

       public PhotoAlbumSearchDataSet.T_AlbumDataTable GetMostPopularAlbums(string appType, int appId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_Album, "P_GetMostPopularAlbums", appType, appId);
           return ds.T_Album;
       }

       public PhotoAlbumSearchDataSet.T_AlbumDataTable GetAllPublicAlbums(string appType, int appId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_Album, "P_GetAllAlbums", appType, appId);
           return ds.T_Album;
       }

       public PhotoAlbumSearchDataSet.T_AlbumDataTable GetWorkgroupAlbums(string appType, int appId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_Album, "P_GetAllAlbums", appType, appId);
           return ds.T_Album;
       }

       public PhotoAlbumSearchDataSet.T_AlbumDataTable GetCommitteeAlbums(string appType, int appId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_Album, "P_GetAllAlbums", appType, appId);
           return ds.T_Album;
       }

       public PhotoAlbumSearchDataSet.T_AlbumDataTable GetMySelfAlbums(string appType, int appId, int staffId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_Album, "P_GetMyContributionsAlbums", appType, appId, staffId);
           return ds.T_Album;
       }

       public PhotoAlbumSearchDataSet.T_AlbumContentDataTable GetMadieById(int madieId)
       {
           PhotoAlbumSearchDataSet.T_AlbumContentDataTable dt = new PhotoAlbumSearchDataSet.T_AlbumContentDataTable();
           base.Helper.Fill(dt, "P_GetMediaById", madieId);
           return dt;
       }
       
       public PhotoAlbumSearchDataSet.T_AlbumContentDataTable GetMadieByAlbumId(int albumId)
       {
           PhotoAlbumSearchDataSet.T_AlbumContentDataTable dt = new PhotoAlbumSearchDataSet.T_AlbumContentDataTable();
           base.Helper.Fill(dt, "P_GetMediaByAlbumId", albumId);
           return dt;
       }

       public PhotoAlbumSearchDataSet.T_SearchLikeDataTable GetLike(int objectId, string objectType)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_SearchLike, "P_GetLike", objectId, objectType);
           return ds.T_SearchLike;
       }

       public void LikeOfAlbum(PhotoAlbumSearchDataSet ds)
       {
           Helper.ExecuteNonQuery("P_Like_I_OR_D", ds.T_Like[0].LikeId, ds.T_Like[0].StaffId, ds.T_Like[0].LikeObjectId, ds.T_Like[0].LikeObjectType, ds.T_Like[0].CREATED_BY, ds.T_Like[0].CREATED_TIME, Guid.NewGuid().ToString());
       }

       public PhotoAlbumSearchDataSet.T_UserCommitteeDataTable GetUserCommitteeByUserId(int userId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_UserCommittee, "P_UserCommittee_S_UserId", userId);
           return ds.T_UserCommittee;
       }

       public PhotoAlbumSearchDataSet.T_UserDepartmentDataTable GetUserDepartmentByUserId(int userId)
       {
           PhotoAlbumSearchDataSet ds = new PhotoAlbumSearchDataSet();
           base.Helper.Fill(ds.T_UserDepartment, "P_UserDepartment_S_UserId", userId);
           return ds.T_UserDepartment;
       }
    }
}
